package org.tong.order.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.tong.order.service.OrderService;

import javax.print.attribute.standard.MediaSize;
import javax.websocket.server.PathParam;
import java.util.Date;

/**
 * @author
 * @date 2022-12-21 15:40
 */
@RestController
public class OrderController {

    @RequestMapping("/")
    public String index() {
        return "Welcome to orderService";
    }

    @Autowired
    private OrderService orderService;

    @RequestMapping("/at/trx/{id}/{name}")
    public String atTrx(@PathVariable(name = "id") Long id, @PathVariable(name = "name") String name) {
        orderService.addOrderAndAccount(id, name);
        return "finish " + new Date();
    }

    @RequestMapping("/tcc/trx/{id}/{amount}")
    public String tccTrx(@PathVariable(name = "id") Long id, @PathVariable(name = "amount") Long amount) {
        orderService.addAmountByTcc(id, amount);
        return "finish tcc" + new Date();
    }
}
